package types

import (
	"encoding/json"
	"errors"
)

type GetReqData struct {
	Text string `json:"text"`
}

func GetMessageData[T any](s string) (T, error) {
	var (
		data T
	)
	err := json.Unmarshal([]byte(s), &data)
	if err != nil {
		return data, errors.New("请传入json，" + err.Error())
	}
	return data, nil
}
func GetServiceMessage(t int, data string) ServiceMessage {
	var (
		s = ServiceMessage{}
	)
	s.Type = t
	s.Data = data
	return s
}
